import React from 'react';
import styles from './TodoInput.css';

function TodoInput(props) {
  // let {todos}=props
  // console.log(todos)
  let input
  return (
    <div className={styles.normal}>
      <input ref={x=>input=x} type="text"/>
      <button

        onClick={()=>{if (''==input.value.trim()){
          alert('请输入内容')
          input.focus
        }
        else {props.dispatch ({type:'todos/add',
          text:input.value
        }),input.value=''
        }
        }
        }>+</button>
    </div>
  );
}

export default TodoInput;
